package com.jk.mapper;

import com.jk.entity.Order;
import com.jk.entity.Use;
import com.jk.entity.User;
import com.jk.entity.dx;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * Created by 动物的 on 2017/12/19.
 */
public interface UserMapper {
//测试
    @Select("select * from t_user")
    //property实体类中的属性，column对应数据库中的字段名，@Results相当于resultMap
    @Results({
            @Result(property ="userId",column = "userId"),//id
            @Result(property ="userName",column = "userName"),//账号
            @Result(property ="userPassword",column = "userPassword"),//密码
            @Result(property ="realName",column = "realName"),//真实姓名
            @Result(property ="phoneNumber",column = "phoneNumber"),//手机号
            @Result(property ="astrict",column = "astrict"),//短信限制
            @Result(property ="loginAstrict",column = "loginAstrict"),//登录限制
            @Result(property ="userType",column = "userType"),//用户类型
            @Result(property ="idCard",column = "idCard"),//身份证号
            @Result(property ="home",column = "home")//家庭住址
             })

     public List<User> selectUser();
    //登陆
    @Select("select * from t_user where userName=#{userName}")
    @Results({
            @Result(property ="userId",column = "userId"),//id
            @Result(property ="userName",column = "userName"),//账号
            @Result(property ="userPassword",column = "userPassword"),//密码
            @Result(property ="realName",column = "realName"),//真实姓名
            @Result(property ="phoneNumber",column = "phoneNumber"),//手机号
            @Result(property ="astrict",column = "astrict"),//短信限制
            @Result(property ="loginAstrict",column = "loginAstrict"),//登录限制
            @Result(property ="userType",column = "userType"),//用户类型
            @Result(property ="idCard",column = "idCard"),//身份证号
            @Result(property ="home",column = "home")//家庭住址
    })
    public User loginout(String userName);
    //注册
    //身份证验重
    @Select("select * from t_user where idCard=#{idCard}")
    @Results({
            @Result(property ="userId",column = "userId"),//id
            @Result(property ="userName",column = "userName"),//账号
            @Result(property ="userPassword",column = "userPassword"),//密码
            @Result(property ="realName",column = "realName"),//真实姓名
            @Result(property ="phoneNumber",column = "phoneNumber"),//手机号
            @Result(property ="astrict",column = "astrict"),//短信限制
            @Result(property ="loginAstrict",column = "loginAstrict"),//登录限制
            @Result(property ="userType",column = "userType"),//用户类型
            @Result(property ="idCard",column = "idCard"),//身份证号
            @Result(property ="home",column = "home")//家庭住址

    })
    public User shengfenzhengyancheng(String idCard);

    //修改登录次数
    @Update("update t_user set loginAstrict=loginAstrict+'1' " +
            "where userId=#{userId}")
    public Integer xiugaidnelucishu(String userId);
    //用户注册
    @Insert("insert into t_user values(#{userId},#{userName},#{userPassword}," +
            "#{realName},#{phoneNumber},#{astrict},#{loginAstrict},#{userType}," +
            "#{idCard},#{home},#{payPassword})")
    public Integer addzhuceh(User user);

    //查询user表手机号
    @Select("select * from t_user where phoneNumber=#{phoneNumber}")
    @Results({
            @Result(property ="userId",column = "userId"),//id
            @Result(property ="userName",column = "userName"),//账号
            @Result(property ="userPassword",column = "userPassword"),//密码
            @Result(property ="realName",column = "realName"),//真实姓名
            @Result(property ="phoneNumber",column = "phoneNumber"),//手机号
            @Result(property ="astrict",column = "astrict"),//短信限制
            @Result(property ="loginAstrict",column = "loginAstrict"),//登录限制
            @Result(property ="userType",column = "userType"),//用户类型
            @Result(property ="idCard",column = "idCard"),//身份证号
            @Result(property ="home",column = "home")//家庭住址

    })
    public User shoujihaochaxun(String phoneNumber);

    //查询验证表手机号
    @Select("select * from dx where shoujihao=#{shoujihao}")
    @Results({
            @Result(property ="id",column = "id"),//id
            @Result(property ="shoujihao",column = "shoujihao"),//手机号
            @Result(property ="cishu",column = "cishu")//次数
    })
    public dx chaxunhsoujihao(String shoujihao);

    //新增数据
    @Insert("insert into dx values(#{id},#{shoujihao},#{cishu})")
    public Integer insertdaunxian(dx dxx);

    //修改短信次数
    @Update("update dx set cishu=cishu+'1' where shoujihao=#{shoujihao}")
    public Integer updateduanxincishu(String shoujihao);
    //depe部门表
    @Select("select  ID as id, TEXT as name, PID as pid from t_6A_dept")
    List<Map> selectDeptTree();
    //角色表
    @Select("select userId as id,  userName as name,deptId as pid from t_6a_user ")
    List<Map> selectUserTreeDept();

    //查询应用详情
    @Select("select * from t_use where userId=#{userId}")
    @Results({
            @Result(property ="useid",column = "useId"),//应用id
            @Result(property ="usename",column = "useName"),//应用名称
            @Result(property ="appid",column = "appId"),//AppID
            @Result(property ="userid",column = "userId"),//创建人（用户）id
            @Result(property ="publickey",column = "publicKey"),//公钥
            @Result(property ="shopid",column = "shopId"),//商铺id
            @Result(property ="usestatus",column = "useStatus")//应用状态

    })
    //查询应用详情
    public List<Use> yingyongxingqing(String userId);
    //新增应用
    @Insert("insert into t_use values(#{useid},#{usename},#{appid}," +
            "#{userid},#{publickey},#{shopid},#{usestatus})")
    //新增应用
    public void  addsxingzheng(Use use);
//根据Appid 查询出来一条数据  判断秘钥对不对
    @Select("select * from t_use where appId=#{appid}")
    @Results({
            @Result(property ="useid",column = "useId"),//应用id
            @Result(property ="usename",column = "useName"),//应用名称
            @Result(property ="appid",column = "appId"),//AppID
            @Result(property ="userid",column = "userId"),//创建人（用户）id
            @Result(property ="publickey",column = "publicKey"),//公钥
            @Result(property ="shopid",column = "shopId"),//商铺id
            @Result(property ="usestatus",column = "useStatus")//应用状态
    })
    //根据Appid 查询出来一条数据  判断秘钥对不对
    public Use panduanmiyuao(String appid);


    @Select("select * from zjj_order where ddid=#{ddid}")
    @Results({
            @Result(property ="ddid",column = "ddid"),//id
            @Result(property ="ddjine",column = "ddjine"),//金额
            @Result(property ="ddtime",column = "ddtime"),//时间
            @Result(property ="ddstatus",column = "ddstatus"),//状态
            @Result(property ="gluserid",column = "gluserid"),//用户id
            @Result(property ="glsnappid",column = "glsnappid"),//商家id
            @Result(property ="ddname",column = "ddname")//商品名称
    })
    //查询订单状态
    public Order chaxundingdianzhuangtai(String ddid);
    //删除应用
    @Delete("delete from t_use where useid=#{useid}")
    //删除应用
    public Integer delectzjj(String useid);

    @Insert("insert into zjj_order values(#{ddid},#{ddjine},#{ddtime},#{ddstatus},#{gluserid}," +
            "#{glsnappid},#{ddname})")
    //添加购买商品信息
    public Integer tianjaishangpainxianxin(Order order);
}
